package com.fet.batchTask;

import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.fet.util.HttpHandler;
import com.fet.util.impl.HttpHandlerHttpClientImpl;


/**
 * @author Derek
 * @date:Sep 23, 2011 3:54:14 PM
 * @version :
 */

public class BatchTask implements Runnable {
	
	Log log = LogFactory.getLog(BatchTask.class );
	
	String batchId ;
	String batchAction ;
	String url;
	
	public BatchTask(){
		
	}
	
	public BatchTask(String batchId,String batchAction,
			String url){
		this.batchId = batchId;
		this.batchAction = batchAction;
		this.url = url;
	}
	
	public String getBatchId() {
		return batchId;
	}
	public void setBatchId(String batchId) {
		this.batchId = batchId;
	}
	public String getBatchAction() {
		return batchAction;
	}
	public void setBatchAction(String batchAction) {
		this.batchAction = batchAction;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}

	public void run() {
		try{
			HttpHandler httpClient = new HttpHandlerHttpClientImpl();
			Properties params = new Properties();
			params.setProperty("action", batchAction);
			params.setProperty("batchId", batchId);
			params.setProperty("temp", "" + Math.random());
			
			log.info("start a calling ,action=" + url 
					+ "; batchId=" + batchId);	
			httpClient.execMethod(url , params, 0, 0);
			log.info("end a calling ,action=" + url 
					+ "; batchId=" + batchId);
			
		}catch(Throwable e){
			log.error(e);
		}
	}

}
